//sxy bless pr
#include<bits/stdc++.h>
using namespace std;
int t;
int n,m,l,V;
int d[100005],v[100005],a[100005],p[100005];
bool cs[100005];
int ss[100005],sc[100005],ec[100005];
struct rg{
    int l,r;
    bool operator < (const rg &b) const{
        return r<b.r;
    }
}as[100005];
void solve(){
    scanf("%d%d%d%d",&n,&m,&l,&V);
    for(int i=1;i<=n;i++) scanf("%d%d%d",&d[i],&v[i],&a[i]);
    for(int i=1;i<=m;i++) scanf("%d",&p[i]);
    memset(cs,0,sizeof(cs));
    memset(as,0,sizeof(as));
    int l,r,mid,v_2;
    int ans=0;
    for(int i=1;i<=n;i++){
        if(d[i]>p[m]) continue;
        l=1,r=m;
        while(l<r){
            mid=(l+r)>>1;
            if(p[mid]>=d[i]) r=mid;
            else l=mid+1;
        }
        ss[i]=r;
        if(a[i]<0){
            v_2=v[i]*v[i]+2*a[i]*(p[ss[i]]-d[i]);
            if(v_2<=V*V) continue;
            l=ss[i],r=m;
            //for(int j=ss[i];j<=m;j++) if(v[i]*v[i]+2*a[i]*(p[j]-d[i])>V*V) as[i].r=j;
            while(l<r){
                mid=(l+r)>>1;
                if(v[i]*v[i]+2*a[i]*(p[mid]-d[i])<=V*V) r=mid;
                else l=mid+1;
            }
            while(v[i]*v[i]+2*a[i]*(p[r]-d[i])<=V*V) r--;
            as[i].l=ss[i],as[i].r=r;
        }
        else{
            v_2=v[i]*v[i]+2*a[i]*(p[m]-d[i]);
            if(v_2<=V*V) continue;
            l=ss[i],r=m;
            while(l<r){
                mid=(l+r)>>1;
                if(v[i]*v[i]+2*a[i]*(p[mid]-d[i])>=V*V) r=mid;
                else l=mid+1;
            }
            as[i].l=r,as[i].r=m;
        }
        cs[i]=1;
    }
    int cnt=0;
    sort(as+1,as+n+1);
    for(int i=1,j=0;i<=n;i++){
        if(as[i].l==0&&as[i].r==0) continue;
        if(j<as[i].l) ans++,j=as[i].r;
    }
    int maxn=-1,minn=m+1;
    for(int i=1;i<=n;i++) cnt+=cs[i];
    cout<<cnt<<' '<<m-ans<<endl;
}
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    scanf("%d",&t);
    while(t--)
        solve();
    return 0;
}
